import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

public class AdminPanel extends JFrame {
    private ArrayList<Student> students;
    private ArrayList<Teacher> teachers;

    public AdminPanel(ArrayList<Student> students, ArrayList<Teacher> teachers) {
        this.students = students;
        this.teachers = teachers;
        setTitle("管理员面板");
        setSize(400, 300);
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

        JPanel panel = new JPanel();
        add(panel);
        placeComponents(panel);
    }

    private void placeComponents(JPanel panel) {
        panel.setLayout(null);

        JButton manageStudentsButton = new JButton("管理学生");
        manageStudentsButton.setBounds(10, 20, 160, 25);
        panel.add(manageStudentsButton);

        JButton manageTeachersButton = new JButton("管理教师");
        manageTeachersButton.setBounds(10, 60, 160, 25);
        panel.add(manageTeachersButton);

        manageStudentsButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                StudentManagementPanel studentManagementPanel = new StudentManagementPanel(students);
                studentManagementPanel.setVisible(true);
            }
        });

        manageTeachersButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                TeacherManagementPanel teacherManagementPanel = new TeacherManagementPanel(teachers);
                teacherManagementPanel.setVisible(true);
            }
        });
    }
}
